
{//get info
	let storage = window.localStorage;
	var xmlhttp = new XMLHttpRequest();
	var i = 0, array = [], a0 = [], obj = {};
	obj.data = a0;
	a0[0] = array;
	obj.id = storage.id;
	obj.operate = "get_info";
	obj.token = storage.token;
	xmlhttp.open("post", "account/account", false);
	console.log(JSON.stringify(obj));
	xmlhttp.send(JSON.stringify(obj));
	console.log("read:" + xmlhttp.responseText);
	var myObj = JSON.parse(xmlhttp.responseText);
	var array = myObj.data[1];
	i = 0;
	document.getElementById("id").innerHTML = array[i++];
	document.getElementById("pwd").value = array[i++];
	document.getElementById("nickname").value = array[i++];
	document.getElementById("email").value = array[i++];
	document.getElementById("contact").value = array[i++];
	document.getElementById("confirm_pwd").value = "";
}
submit.onclick = function(){//modify
	let storage = window.localStorage;
	var user = document.getElementById('nickname');
	var pwd = document.getElementById('pwd');
	var confirm_pwd = document.getElementById('confirm_pwd');
	if (pwd.value != confirm_pwd.value) {
		console.log("pwd:" + pwd.value + "confirm pwd:" + confirm_pwd.value);
		document.getElementById('error').innerHTML = "错误：两次密码不一样";
	} else if (user.value == "") {
		document.getElementById('error').innerHTML = "错误：昵称不能为空";
	} else {
		var array = [], a0 = [], obj = {};
		var i = 0;
		obj.data = a0;
		a0[1] = array;
		array[i++] = storage.id;
		array[i++] = pwd.value;
		array[i++] = nickname.value;
		array[i++] = email.value;
		array[i++] = contact.value;
		obj.id = storage.id;
		obj.operate = "modify";
		obj.token = storage.token;
		console.log(JSON.stringify(obj));
		var xmlhttp = new XMLHttpRequest();
		xmlhttp.open("post", "account/account", false);
		xmlhttp.send(JSON.stringify(obj));
		console.log(xmlhttp.responseText);
		var myObj = JSON.parse(xmlhttp.responseText);
		if (myObj.error) {
			document.getElementById("error").innerHTML = myObj.error;
		} else if (myObj.token) {
			storage.token = myObj.token;
			storage.id = myObj.id;
			top.window.location.href="../car/driver.html?token=" + storage.token + "&id=" + storage.id;
		}
	}
}
